-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GrapheneIntegration: Track operation name for tracing #2704
base: master
Are you sure you want to change the base?
Conversation
Hi @keithhackbarth, i would love to see this change! |
… query getsentry#2704 This commit adds a missing test for the graphene integration, so that we can be sure that a transaction with the corresponding query name is captured.
… query getsentry#2704 This commit adds a missing test for the graphene integration, so that we can be sure that a transaction with the corresponding query name is captured. --amend
Hey @keithhackbarth, i added a test and made a PR on your fork 😄 |
Feature/add graphene tests
… query getsentry#2704 This commit adds a missing test for the graphene integration, so that we can be sure that a transaction with the corresponding query name is captured. --amend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution! This PR will require some changes before we can merge it; I have described these in an inline comment.
with hub.start_transaction(op="graphql", name=kwargs.get("operation_name")): | ||
result = old_graphql_sync(schema, source, *args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be starting a span here rather than a transaction, since Graphene is likely to be called by a web server's response handler, which would already have a transaction automatically started for it (we integrate with the popular web frameworks, like Flask, Django, etc). Creating a transaction within a transaction leads to undefined behavior; they cannot be nested, so we need a span, not a transaction here.
Since spans do not have a name
, the operation name should be stored in the span's description
instead.
Lastly, the op
should be one of the values listed under the GraphQL category in the "Usage" column of this table.
It is helpful to have the operation's name if trying to track the individual performance of GraphQL transactions using Sentry. This PR implements the approach suggested in this article, as part of the GrapheneIntegration()
Note: I looked and wasn't initially sure how to write a good test for this and also wasn't sure if this PR is even a good idea in the first place. So leaving a light version here for feedback.